package edu.zju.gis.dldsj.type;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yanlo yanlong_lee@qq.com
 * @version 1.0 2018/07/15
 */
public class QueryBuilder {
    String select;
    List<String> filter;
    String where;
    String groupBy;
    String orderBy;
    long offset;
    long size;

    public QueryBuilder() {
        select = "";
        filter = new ArrayList<>();
        where = "";
        groupBy = "";
        orderBy = "";
        offset = 0;
        size = 0;
    }

    public QueryBuilder clear() {
        this.select = "";
        this.filter.clear();
        this.where = "";
        this.groupBy = "";
        this.orderBy = "";
        this.offset = 0;
        this.size = 0;
        return this;
    }

    public QueryBuilder select(String select) {
        this.select = select;
        return this;
    }

    public QueryBuilder filter(String filter) {
        this.filter.add(filter);
        return this;
    }

    public QueryBuilder where(String where) {
        this.where = where;
        return this;
    }

    public QueryBuilder groupBy(String groupBy) {
        this.groupBy = groupBy;
        return this;
    }

    public QueryBuilder orderBy(String orderBy) {
        this.orderBy = orderBy;
        return this;
    }

    public QueryBuilder limit(long offset, long size) {
        this.offset = offset;
        this.size = size;
        return this;
    }

}
